tidy.source {animation}R Documentation

‘Tidy up’ R code

Description

Actually this function has nothing to do with code optimization; it just returns parsed source code.

Usage

tidy.source(source = "clipboard", ...)

Arguments

source a string: location of the source code
... other arguments passed to cat, e.g. file

Details

This function helps the user to tidy up his source code in a sense that necessary indents and spaces will be added, etc. See parse.

Value

None (invisible `NULL'). `Clean' code will be returned to the console unless the output is redirected by `sink'.

Author(s)

Yihui Xie

References

http://animation.yihui.name/animation:misc#tidy_up_r_source

See Also

parse, cat

Examples

## tidy up the source code of image demo 
x = file.path(system.file(package = "graphics"), "demo", "image.R") 
# to console 
tidy.source(x)
# to a file
tidy.source(x, file = tempfile()) 
## check the original code here and see the difference 
file.show(x)

## if you've copied R code into the clipboard 
## Not run: 
tidy.source("clipboard")
## End(Not run)

[Package animation version 1.0-1 Index]